

#include <iostream>
#include <string>
#include "contacts.pb.h"

int main()
{
    // 序列化

    contacts::contact conn;
    conn.set_sn(1001);
    conn.set_name("小明");
    conn.set_score(90);

    std::string str = conn.SerializeAsString();
    // std::cout<<str<<std::endl;

    // 反序列化
    contacts::contact stu;
    bool ret = stu.ParseFromString(str);
    if (ret == false)
    {
        std::cout << "反序列化失败" << std::endl;
    }
    std::cout << stu.sn() << std::endl;
    std::cout << stu.score() << std::endl;
    std::cout << stu.name() << std::endl;

    return 0;
}